﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using readFiles;
using System.Data;
using Npgsql;

namespace DataManagement
{
    public class prestamo
    {
        public static void leerPrestamos()
        {
            Conexion c1 = new Conexion("localhost", "5432", "postgres", "sigeb_pass123", "sigeb_bd");
            LinkedList<string[]> nueva = readExcel.ExcelOpenSpreadsheetsList("C:\\Users\\ragomezr\\Documents\\SIGEB\\BD\\Migracion\\DataManagement\\DataManagement\\bin\\Debug\\Prestamos.xlsx", 5);
            DataSet ds = new DataSet();
            DataSet dataSetActual = new DataSet();
            DataTable dt = new DataTable();
            DataSet dataSetAux = new DataSet();
            c1.conexion.Open();
            foreach (string[] act in nueva)
            {
                string sql = "SELECT * FROM insertaPrestamoMigracion('" + act[0] + "', '" + act[1] + "', '" + act[2] + "', '" + act[3] + "')";
                try
                {
                    NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, c1.conexion);
                    ds.Reset();
                    da.Fill(ds);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + "-------" + act[4]);
                }
            }
            c1.conexion.Close();
            Console.ReadLine();
        }
    }
}
